package com.unswift.window.factory;

import java.awt.Component;

import javax.swing.JOptionPane;

import com.unswift.utils.ThreadUtils;
import com.unswift.window.extend.MessageBack;

public final class MessageFactory {

	public static void error(Component parentComponent, Object message){
		ThreadUtils.execute(new Runnable() {
			@Override
			public void run() {
				JOptionPane.showMessageDialog(parentComponent, message, "错误消息", JOptionPane.ERROR_MESSAGE);
			}
		});
	}
	
	public static void error(Component parentComponent, Object message, MessageBack back){
		ThreadUtils.execute(new Runnable() {
			@Override
			public void run() {
				JOptionPane.showMessageDialog(parentComponent, message, "错误消息", JOptionPane.ERROR_MESSAGE);
				back.execute();
			}
		});
	}
	
	public static void warn(Component parentComponent, Object message){
		ThreadUtils.execute(new Runnable() {
			@Override
			public void run() {
				JOptionPane.showMessageDialog(parentComponent, message, "警告消息", JOptionPane.WARNING_MESSAGE);
			}
		});
	}
	
	public static void info(Component parentComponent, Object message){
		ThreadUtils.execute(new Runnable() {
			@Override
			public void run() {
				JOptionPane.showMessageDialog(parentComponent, message, "系统消息", JOptionPane.INFORMATION_MESSAGE);
			}
		});
	}
	
	public static int confirm(Component parentComponent,Object message){
		return JOptionPane.showConfirmDialog(parentComponent, message, "确认消息", JOptionPane.YES_NO_OPTION);
	}
}
